package spring.cloud.tasks.api.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import spring.cloud.tasks.api.service.TaskService;
import spring.cloud.tasks.api.utils.Response;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Sharding status for specified job.
 */
@RequestMapping("/console/namespaces/{namespace:.+}/jobs/{jobName}/sharding")
public class TaskExecutorListController {

    @Resource
    private TaskService jobService;

    /**
     * 获取作业执行状态
     */
    //@ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)})
    @GetMapping(value = "/getTaskExecutorList")
    public Response getTaskExecutorList(final HttpServletRequest request, @PathVariable String namespace,
                                        @PathVariable String jobName) throws RuntimeException {
        return Response.success(jobService.getTaskExecutorList(namespace, jobName));
    }

}
